package com.zh.kotlin_mvvm.net

import com.zh.common.base.bean.BaseResponse
import com.zh.common.net.RetrofitManager
import com.zh.config.ZjConfig
import com.zh.kotlin_mvvm.bean.ChatBody
import com.zh.kotlin_mvvm.bean.SingleJoke
import com.zh.kotlin_mvvm.bean.TokenBean
import com.zh.kotlin_mvvm.net.bean.LoginBean
import com.zh.kotlin_mvvm.utils.AliOrderInfo
import okhttp3.RequestBody
import retrofit2.http.*

/**
 * 实例化网络请求
 * hostUrl 域名, 默认ZjConfig.base_url，需要修改传入新的域名（新的每次都传）
 */
fun netService(hostUrl: String = ZjConfig.base_url): MainNetService =
    RetrofitManager.apiService(MainNetService::class.java, hostUrl)

interface MainNetService {
    /**
     *
     * @param body  可以固定死
     * @return
     */
    @POST("api/app/user/login")
    suspend fun login(@Body body: RequestBody): BaseResponse<LoginBean?>

    /**
     *
     * @param body  可以固定死
     * @return
     */
    @GET
    suspend fun wxPay(
        @Url url: String,
        @Query("orderId") orderId: String,
        @Query("channelId") channelId: String
    ): BaseResponse<AliOrderInfo>

    @GET("/getSingleJoke")
    suspend fun getSingleJoke(@Query("sid") sid: String) :BaseResponse<SingleJoke?>

    @GET("oauth/2.0/token")
    suspend fun token(@Header("Content-Type") contentType: String,
                      @Query("grant_type") grant_type: String,
                      @Query("client_id") client_id: String,
                      @Query("client_secret") client_secret: String
    ):BaseResponse<String?>
    @POST("rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro")
    suspend fun chat(@Header("Content-Type") contentType: String,
                      @Query("access_token") access_token: String,
                      @Body body: ChatBody
    ):BaseResponse<String?>
}